


function sendSearch(keyword) {
	$.ajax({
		url: "resultSearch", //后台url
		contentType: 'application/json;charset=utf-8',
		type: "get", //类型，POST或者GET
		data: {
			"keyword": keyword
		},
		dataType: 'json', //数据返回类型，可以是xml、json等
		success: function(data) { //成功，回调函数
			var json = eval(data);
			var str = "";
			for(var i = 0; i < json.length; i++) {
				str +=
	                  '<div class="search-grid">' + 
	                  '<div class="search-grid-img">' +
	                  '<a href="#"><img src="images/art-img2.jpg"></a>' +
	                  '</div>' +
	                  '<div class="search-grid-info">' +
	                  '<h3>' + json[i].diseaseName + '</h3>' +'<hr />'+
	                  '<span>症状</span>'+ '<p>' + json[i].diseaseSymptoms + '</p>' +'<hr />'+
/*	                  '<p>' + json[i].precautions + '</p>' +
	                  '<p>' + json[i].recipe + '</p>' +*/
	                  '<span>药物治疗</span>'+'<p>' + json[i].medicalTreatement + '</p>' +
	                  '</div>' +
	                  '<div class="clear"> </div>' +
	                  '</div>'
			};
			$(".search-grid").remove();
			str = flagKeyword(str, keyword);
			$("#resultStart").append(str);
			$("h3").css("color", "#9edaec");

		},
		error: function(er) { //失败，回调函数
			alert("error");
		}
	});
}


function flagKeyword(str, keyword) {
	var reg = new RegExp("(" + keyword + ")", "g");
	return str.replace(reg, "<font class='keyword'>$1</font>");
}

function getRequest() {
  var url = window.location.search; //获取url中"?"符后的字串
  var theRequest = new Object();
  if (url.indexOf("?") != -1) {
    var str = url.substr(1);
    strs = str.split("&");
    for(var i = 0; i < strs.length; i ++) {      
      theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);      
    }
  }
  return theRequest;
}

var tempKeyword = getRequest().keyword;



$(document).ready(function() {
	$(".search-pagenat").hide();
	$("#search").click(function() {
		var keyword = $("#keyword").val();
		sendSearch(keyword)
	})
	
	var tempKeyword = getRequest().keyword;
	if(tempKeyword != null ){
	$('#keyword').val(tempKeyword)
	/*alert(tempKeyword);*/
	
	sendSearch(tempKeyword)
	}
})